$(function() {
    $(".form-discuss").on("submit", function(e) {
        e.preventDefault();
        $.ajax({
            headers: { ReturnTo: window.location.pathname },
            url: "/add-discuss",
            method: "post",
            data: {
                commentId: $(".comment-id").val(),
                content: $(".discuss-content").val()
            },
            success: function(data) {
                var username = localStorage.getItem("username");
                if (data.status == -1) {
                    window.location.href = data.goto;
                } else {
                    var html =
                        '<li> <div class="discuss-body">' +
                        "<h5>游客" + username + "<span>：" +
                        $(".discuss-content").val() + "</span></h5>" +
                        "</div></li>";
                    $(".discuss-list").prepend($(html));
                }
            }
        });
    });
});